{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "5d09f14d-a726-4563-8e2d-c80d21306f6d",
   "metadata": {},
   "source": [
    "Product Discovery\n",
    "=================\n",
    "\n",
    "\n",
    "Product Listings\n",
    "----------------\n",
    "Once a datacube instance has been created, users can explore the products and measurements stored within.\n",
    "\n",
    "The datacube instance's `list_products` method can be used to view a list of all products available in the datacube.\n",
    "\n",
    "Products listed under **name** in the following table represent the product options available when querying the datacube. \n",
    "The table below provides some useful information about each product, including a brief product **description**, the data’s **license**, and the product’s default **crs** (coordinate reference system) and **resolution** if applicable."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b6d9e4ca-aac2-4bdd-97d6-601ee9c43670",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>description</th>\n",
       "      <th>license</th>\n",
       "      <th>default_crs</th>\n",
       "      <th>default_resolution</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>name</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>ls5_sr</th>\n",
       "      <td>ls5_sr</td>\n",
       "      <td>USGS Landsat 5 Collection 2 Level-2 Surface Re...</td>\n",
       "      <td>CC-BY-4.0</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ls7_sr</th>\n",
       "      <td>ls7_sr</td>\n",
       "      <td>USGS Landsat 7 Collection 2 Level-2 Surface Re...</td>\n",
       "      <td>CC-BY-4.0</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ls8_sr</th>\n",
       "      <td>ls8_sr</td>\n",
       "      <td>USGS Landsat 8 Collection 2 Level-2 Surface Re...</td>\n",
       "      <td>CC-BY-4.0</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ls9_sr</th>\n",
       "      <td>ls9_sr</td>\n",
       "      <td>USGS Landsat 9 Collection 2 Level-2 Surface Re...</td>\n",
       "      <td>CC-BY-4.0</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          name                                        description    license  \\\n",
       "name                                                                           \n",
       "ls5_sr  ls5_sr  USGS Landsat 5 Collection 2 Level-2 Surface Re...  CC-BY-4.0   \n",
       "ls7_sr  ls7_sr  USGS Landsat 7 Collection 2 Level-2 Surface Re...  CC-BY-4.0   \n",
       "ls8_sr  ls8_sr  USGS Landsat 8 Collection 2 Level-2 Surface Re...  CC-BY-4.0   \n",
       "ls9_sr  ls9_sr  USGS Landsat 9 Collection 2 Level-2 Surface Re...  CC-BY-4.0   \n",
       "\n",
       "       default_crs default_resolution  \n",
       "name                                   \n",
       "ls5_sr        None               None  \n",
       "ls7_sr        None               None  \n",
       "ls8_sr        None               None  \n",
       "ls9_sr        None               None  "
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import datacube\n",
    "\n",
    "dc = datacube.Datacube(app=\"my_analysis\")\n",
    "\n",
    "dc.list_products()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f3b065b1-df3b-4197-b77d-142e5beb6624",
   "metadata": {},
   "source": [
    "## Measurement Listings\n",
    "Most products are associated with a range of available measurements. \n",
    "These can be individual satellite bands (e.g. Landsat’s near-infrared band) or statistical product summaries.\n",
    "\n",
    "The datacube instance's `list_measurements` method can be used to interrogate the measurements associated with a specific product.\n",
    "\n",
    "The table below includes a range of technical information about each band in the `ls9_sr` product (USGS Landsat 9 Collection 2 Level-2 Surface Reflectance). \n",
    "This includes the measurement name, data type (dtype), data units, nodata values, any aliases which can be used to load the measurements, and any flags definitions associated with the measurement (this information is used for tasks like cloud masking)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "0114d31a-4cfa-4a74-b27b-33a689ff4024",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>dtype</th>\n",
       "      <th>units</th>\n",
       "      <th>nodata</th>\n",
       "      <th>aliases</th>\n",
       "      <th>flags_definition</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>product</th>\n",
       "      <th>measurement</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"10\" valign=\"top\">ls9_sr</th>\n",
       "      <th>SR_B1</th>\n",
       "      <td>SR_B1</td>\n",
       "      <td>uint16</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>[band_1, coastal_aerosol]</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SR_B2</th>\n",
       "      <td>SR_B2</td>\n",
       "      <td>uint16</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>[band_2, blue]</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SR_B3</th>\n",
       "      <td>SR_B3</td>\n",
       "      <td>uint16</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>[band_3, green]</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SR_B4</th>\n",
       "      <td>SR_B4</td>\n",
       "      <td>uint16</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>[band_4, red]</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SR_B5</th>\n",
       "      <td>SR_B5</td>\n",
       "      <td>uint16</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>[band_5, nir]</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SR_B6</th>\n",
       "      <td>SR_B6</td>\n",
       "      <td>uint16</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>[band_6, swir_1]</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SR_B7</th>\n",
       "      <td>SR_B7</td>\n",
       "      <td>uint16</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>[band_7, swir_2]</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>QA_PIXEL</th>\n",
       "      <td>QA_PIXEL</td>\n",
       "      <td>uint16</td>\n",
       "      <td>bit_index</td>\n",
       "      <td>1.0</td>\n",
       "      <td>[pq, pixel_quality]</td>\n",
       "      <td>{'snow': {'bits': 5, 'values': {'0': 'not_high...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>QA_RADSAT</th>\n",
       "      <td>QA_RADSAT</td>\n",
       "      <td>uint16</td>\n",
       "      <td>bit_index</td>\n",
       "      <td>0.0</td>\n",
       "      <td>[radsat, radiometric_saturation]</td>\n",
       "      <td>{'nir_saturation': {'bits': 4, 'values': {'0':...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SR_QA_AEROSOL</th>\n",
       "      <td>SR_QA_AEROSOL</td>\n",
       "      <td>uint8</td>\n",
       "      <td>bit_index</td>\n",
       "      <td>1.0</td>\n",
       "      <td>[qa_aerosol, aerosol_qa]</td>\n",
       "      <td>{'water': {'bits': 2, 'values': {'0': False, '...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                name   dtype      units  nodata  \\\n",
       "product measurement                                               \n",
       "ls9_sr  SR_B1                  SR_B1  uint16          1     0.0   \n",
       "        SR_B2                  SR_B2  uint16          1     0.0   \n",
       "        SR_B3                  SR_B3  uint16          1     0.0   \n",
       "        SR_B4                  SR_B4  uint16          1     0.0   \n",
       "        SR_B5                  SR_B5  uint16          1     0.0   \n",
       "        SR_B6                  SR_B6  uint16          1     0.0   \n",
       "        SR_B7                  SR_B7  uint16          1     0.0   \n",
       "        QA_PIXEL            QA_PIXEL  uint16  bit_index     1.0   \n",
       "        QA_RADSAT          QA_RADSAT  uint16  bit_index     0.0   \n",
       "        SR_QA_AEROSOL  SR_QA_AEROSOL   uint8  bit_index     1.0   \n",
       "\n",
       "                                                aliases  \\\n",
       "product measurement                                       \n",
       "ls9_sr  SR_B1                 [band_1, coastal_aerosol]   \n",
       "        SR_B2                            [band_2, blue]   \n",
       "        SR_B3                           [band_3, green]   \n",
       "        SR_B4                             [band_4, red]   \n",
       "        SR_B5                             [band_5, nir]   \n",
       "        SR_B6                          [band_6, swir_1]   \n",
       "        SR_B7                          [band_7, swir_2]   \n",
       "        QA_PIXEL                    [pq, pixel_quality]   \n",
       "        QA_RADSAT      [radsat, radiometric_saturation]   \n",
       "        SR_QA_AEROSOL          [qa_aerosol, aerosol_qa]   \n",
       "\n",
       "                                                        flags_definition  \n",
       "product measurement                                                       \n",
       "ls9_sr  SR_B1                                                        NaN  \n",
       "        SR_B2                                                        NaN  \n",
       "        SR_B3                                                        NaN  \n",
       "        SR_B4                                                        NaN  \n",
       "        SR_B5                                                        NaN  \n",
       "        SR_B6                                                        NaN  \n",
       "        SR_B7                                                        NaN  \n",
       "        QA_PIXEL       {'snow': {'bits': 5, 'values': {'0': 'not_high...  \n",
       "        QA_RADSAT      {'nir_saturation': {'bits': 4, 'values': {'0':...  \n",
       "        SR_QA_AEROSOL  {'water': {'bits': 2, 'values': {'0': False, '...  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dc.list_measurements()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
